home *** CD-ROM | disk | FTP | other *** search
/ Creative Review 28 / Creative-Review-CD-ROM-28.iso / pc / kungfu / assets / game.dir / 00016_Script_back class < prev    next >
Text File  |  1997-08-08  |  5KB  |  232 lines

  1. -- back class
  2. -- ==================================================
  3.  
  4. property old
  5. property new
  6.  
  7. property centrestage 
  8. property offstageright
  9. property offstageleft
  10.  
  11. property shapeoffset
  12. property shaperect
  13. property stepvector
  14.  
  15. property props
  16.  
  17. property animflag
  18.  
  19. property callbackcount
  20.  
  21. global ggame, gtime, gplayer, gboss, gsound
  22.  
  23. -- ==================================================
  24. -- new method
  25. -- --------------------------------------------------
  26. on new me
  27.   
  28.   minit me
  29.   
  30.   return me
  31.   
  32. end new
  33.  
  34. -- ==================================================
  35. -- minit method
  36. -- --------------------------------------------------
  37. on minit me
  38.   
  39.   --  put "in minit back"
  40.   
  41.   set backlist = []
  42.   set backchannels = [ 1, 2 ]
  43.   set backprops = [:]
  44.   setaprop backprops, #castname, "keys"
  45.   
  46.   repeat with channel in backchannels
  47.     
  48.     setaprop backprops, #channel, channel 
  49.     set back = new ( script "move class" , backprops )
  50.     add backlist , back
  51.     
  52.   end repeat
  53.   
  54.   set old = getat ( backlist, 1 )
  55.   set new = getat ( backlist, 2 )
  56.   
  57.   set screen =  point ( 640, 0 )
  58.   set centrestage = point ( 320, 235 )
  59.   set offstageright = centrestage + screen
  60.   set offstageleft = centrestage - screen
  61.   
  62.   set shapeoffset = point ( - 320, - 70 )
  63.   set shaperect = rect(0, 0, 640, 240) - 1000
  64.   
  65.   set stepvector = point ( - 17, 0 )
  66.   
  67.   set animflag = false
  68.   
  69.   --  put "out minit back"
  70.   
  71. end minit
  72.  
  73. -- ==================================================
  74. -- msplat method
  75. -- --------------------------------------------------
  76. on msplat me, backcast
  77.   
  78.   put "in msplat back class :" , backcast
  79.   
  80.   msetcastname new , backcast
  81.   mcheckshape me, backcast
  82.   mdraw new
  83.   
  84.   put "out msplat back class " 
  85.   
  86. end msplat
  87.  
  88. -- ==================================================
  89. -- mcheckshape method
  90. -- --------------------------------------------------
  91. on mcheckshape me, newcast
  92.   
  93.   --  put "in mcheckshape back class " 
  94.   
  95.   if the type of member newcast = #shape then
  96.     --    put "shape"
  97.     msetrect new , shaperect
  98.     msetoffset new , shapeoffset
  99.   else
  100.     --     put "bitmap"
  101.     msetoffset new , point ( 0, 0 )
  102.     msetrect new , the rect of cast newcast
  103.   end if
  104.   
  105.   --  put "out mcheckshape back class "
  106.   
  107. end mcheckshape
  108.  
  109. -- ==================================================
  110. -- mslide method
  111. -- --------------------------------------------------
  112. on mslide me, newbackcast
  113.   
  114.   --  put "in mslide back class :"
  115.   
  116.   set animflag = true
  117.   set callbackcount = 0
  118.   
  119.   set recycle = old
  120.   
  121.   set old = new
  122.   set new = recycle
  123.   
  124.   msetcastname new, newbackcast
  125.   
  126.   mcheckshape me, newbackcast
  127.   
  128.   set props = [:]
  129.   setaprop props, #callback, me
  130.   setaprop props, #targetloc, centrestage
  131.   setaprop props, #startloc, offstageright
  132.   mstartmove new, props
  133.   
  134.   setaprop props, #targetloc, offstageleft
  135.   setaprop props, #startloc, centrestage
  136.   setaprop props, #stepvector, stepvector
  137.   mstartmove old, props
  138.   
  139.   
  140.   -- maddtask gtime, me, the timer
  141.   mdotask me
  142.   
  143.   --  put "out mslide back class :"
  144.   
  145. end mslide
  146.  
  147. -- ==================================================
  148. -- mslide method
  149. -- --------------------------------------------------
  150. on mfinish me
  151.   
  152.   unloadmember the castname of old
  153.   msetcastnumber old, 0
  154.   mdraw old
  155.   updatestage
  156.   
  157.   set animflag = false
  158.   mdeletetasks gtime, me
  159.   
  160.   mfinishslide ggame
  161.   
  162.   --  mshow gtime
  163.   
  164. end mfinish 
  165.  
  166. -- ==================================================
  167. -- mdotask method
  168. -- --------------------------------------------------
  169. on mdotask me
  170.   
  171.   --  put "in mdotask back class :"
  172.   
  173.   --  put "oldtype: " , the oldtype of ggame
  174.   
  175.   repeat while true
  176.     
  177.     mdotask  new
  178.     mdotask  old
  179.     
  180.     if the oldtype of ggame = #boss then
  181.       mmove  gboss, stepvector 
  182.       mmove gplayer, stepvector
  183.       mdraw gboss
  184.       mdraw gplayer
  185.     else if the oldtype of ggame = #baddy then
  186.       mmove gplayer, stepvector
  187.       mdraw gplayer
  188.     end if
  189.     
  190.     updatestage
  191.     
  192.     if not animflag then exit repeat
  193.     
  194.   end repeat
  195.   
  196.   return false
  197.   
  198.   put "out mdotask back class :"
  199.   
  200. end mdotask
  201.  
  202. -- ==================================================
  203. -- mcallback method
  204. -- --------------------------------------------------
  205. on mcallback me
  206.   
  207.   --  put "in mcallback back"
  208.   
  209.   set callbackcount = callbackcount + 1
  210.   
  211.   if callbackcount = 2 then
  212.     mfinish me
  213.   end if
  214.   
  215.   --  put "out mcallback back"
  216.   
  217. end mcallback
  218.  
  219. -- ==================================================
  220. -- mshow method
  221. -- --------------------------------------------------
  222. on mshow me
  223.   
  224.   put "in mshow back class :"
  225.   
  226.   puto me
  227.   putl backlist
  228.   
  229.   put "out mshow back class :"
  230.   
  231. end mshow
  232.